FROM  ubuntu:18.04 
WORKDIR /speech
RUN echo "[Update System]" \
    && sed -i 's/archive.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list\
    && apt update \
    && echo "[Install Python & PyPI]"\
    && apt install -y build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev libsqlite3-dev wget libbz2-dev swig curl git liblzma-dev\
    && cd /mnt/\
    && wget https://mirrors.huaweicloud.com/python/3.10.9/Python-3.10.9.tgz\
    && tar -xf Python-3.10.9.tgz -C /usr/local/lib\
    && cd /usr/local/lib/Python-3.10.9\
    && ./configure --enable-optimizations\
    && make -j$(cat /proc/stat | grep cpu[0-9] -c)\
    && make altinstall\
    && ln -s $(which python3.10) /usr/bin/python\
    && ln -s $(which pip3.10) /usr/bin/pip\
    && pip config set global.index-url https://mirror.baidu.com/pypi/simple\
    && echo "[Install Paddle]" \
    && pip install pandas nltk librosa uvicorn fastapi pytest-runner aiofiles faiss-cpu python-multipart paddlepaddle==2.5.1 pytest-runner backports.lzma\
    && echo "[Install Speech]" \
    && mkdir -p /speech/src\
    && cd /speech/src\
    && git clone https://gitee.com/ray0728/PaddleSpeech.git\
    && cd /speech/src/PaddleSpeech/\
    && cp -r /speech/src/PaddleSpeech/demos/speech_web/speech_server/ /speech/server/\
    && cp -r /speech/src/PaddleSpeech/demos/speech_web/web_client/ /speech/client/\
    && pip install .\
    && cd /speech/server \
    && mkdir -p source/model/ \
    && wget https://bj.bcebos.com/paddlenlp/applications/speech-cmd-analysis/finetune/model_state.pdparams -O source/model/model_state.pdparams  \
    && echo "[Install NodeJs]"\
    && curl -fsSL https://deb.nodesource.com/setup_16.x | bash\
    && apt install -y nodejs\
    && npm config set registry http://registry.npmmirror.com\
    && npm install -g  yarn \
    && npm install vue\
    && npm install -g @vue/cli\
    && echo "[Clean]"\
    && rm -rf /mnt/*\
    && rm -rf /speech/src

